package com.lg.erp.service.impl.chenjunhui;

import com.lg.erp.entity.chenjunhui.TProductHandover;
import com.lg.erp.mapper.chenjunhui.TProductHandoverMapper;
import com.lg.erp.service.chenjunhui.ITProductHandoverService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;
import java.util.UUID;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lg
 * @since 2021-04-21
 */
@Service
public class TProductHandoverServiceImpl extends ServiceImpl<TProductHandoverMapper, TProductHandover> implements ITProductHandoverService {

    @Autowired
    private TProductHandoverMapper tProductHandoverMapper;

    @Override
    public void addTProductHandover(TProductHandover tProductHandover) {
        String substring = UUID.randomUUID().toString().substring(0, 6);
        tProductHandover.setId(substring);
        tProductHandover.setState(0);
        tProductHandover.setType(0);
        tProductHandoverMapper.insertTProductHandover(tProductHandover);
    }

    @Override
    public int getTProductHandoverCount(String formInlineId, String formInlineDate) {
        return tProductHandoverMapper.selectTProductHandoverCount("%"+formInlineId+"%","%" + formInlineDate + "%");
    }

    @Override
    public List<TProductHandover> getTProductHandoverPage(Integer pageNum, Integer pageSize, String formInlineId, String formInlineDate) {
        pageNum=(pageNum-1)*pageSize;
        return tProductHandoverMapper.selectTProductHandoverPage(pageNum,pageSize,"%"+formInlineId+"%","%" + formInlineDate + "%");
    }

    @Override
    public TProductHandover getItProductHandover(String id) {
        return tProductHandoverMapper.selectItProductHandover(id);
    }

    @Override
    public int getAllCount(String inp) {
        return tProductHandoverMapper.selectAllCount(inp);
    }

    @Override
    public List<TProductHandover> getAllTProductHandoverPage(Integer pageNum, Integer pageSize, String inp) {
        pageNum=(pageNum-1)*pageSize;
        return tProductHandoverMapper.selectAllTProductHandoverPage(pageNum,pageSize,"%"+inp+"%");
    }
}
